home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / compguid / collectn / lukuptbl.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  1.8 KB  |  68 lines  |  [TEXT/ttxt]

  1. --<<<
  2.  
  3. object lookupTable (HashTable) end
  4. add lookupTable @groink (a b -> processGroink a b)
  5. add lookupTable @ululate (a b -> processUlulate a b)
  6. add lookupTable @giggle (a b -> processGiggle a b)
  7.  
  8. object kiwi (Rect) 
  9.     x2:100, y2:100 
  10.     instance variables 
  11.         name:"baah", activity:@groink
  12. end
  13.  
  14. object aussie (TextPresenter) 
  15.      boundary:(new Rect x2:50 y2:100), \
  16.         target:("gudday mate" as String)
  17.     instance variables 
  18.         name:"mathilda", activity:@ululate
  19. end
  20.  
  21. object texan (MouseUpEvent) 
  22.     x2:100, y2:100 
  23.     instance variables 
  24.         name:"hazel", activity:@giggle
  25. end
  26.  
  27. object sourceTable (LinkedList) end
  28. append sourceTable kiwi
  29. append sourceTable texan
  30. append sourceTable aussie
  31.  
  32. global readTable
  33. class ActivityReader (RootObject)
  34.     instance methods
  35.         method readTable self source table -> (
  36.             if not isAKindOf table ExplicitlyKeyedCollection do
  37.                 report badParameter #(table, self, readTable,
  38.                     "Expected an explicitly keyed collection")
  39.             if isAKindOf source LinearCollection then (
  40.                 local i := iterate source
  41.                 repeat while (next i) do (
  42.                     if hasKey table (i.value.activity) then 
  43.                         table[i.value.activity] self i.value
  44.                     else
  45.                         report generalError "missing table entry"
  46.                 )
  47.             )
  48.             else (
  49.                 report badParameter #(source, self, readTable,
  50.                     "Expected a linear collection")
  51.             )
  52.         )
  53.         method processGroink self obj ->
  54.             format debug "Object %1, of class %2, just groinked.\n" \
  55.                 #(obj.name, (getClass obj))
  56.         method processUlulate self obj ->
  57.             format debug "Object %1, of class %2, just ululated.\n" \
  58.                 #(obj.name, (getClass obj))
  59.         method processGiggle self obj ->
  60.             format debug "Object %1, of class %2, just giggled.\n" \
  61.                 #(obj.name, (getClass obj))
  62. end
  63.  
  64. global myActivityReader := new ActivityReader
  65. readTable myActivityReader sourceTable lookupTable
  66.  
  67. -->>>
  68.